import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/cardvolume', component: () => import('@/views/cardvolume'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    name: 'home',
    hidden: false,
    children: [{
      path: 'home',
      component: () => import('@/views/home/index'),
      meta: { title: '首页', icon: 'form' }
    }]
  },

  // {
  //   path: '/conntrol',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Control',
  //       component: () => import('@/views/control/index'),
  //       meta: { title: '控制台', icon: 'form' }
  //     }
  //   ]
  // },
  {
    path: '/routine',
    component: Layout,
    redirect: '/routine/personal',
    name: 'routline',
    meta: { title: '常规管理', icon: 'example' },
    children: [
      {
        path: 'personal',
        name: 'Personal',
        component: () => import('@/views/routine/personal/index'),
        meta: { title: '个人中心', icon: 'table' }
      },
      {
        path: 'system',
        name: 'System',
        component: () => import('@/views/routine/system/index'),
        meta: { title: '系统配置', icon: 'tree' }
      }
    ]
  },

  {
    path: '/weixin',
    component: Layout,
    redirect: '/weixin/autoreply',
    name: 'Weixin',
    meta: {
      title: '微信管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'autoreply',
        component: () => import('@/views/weixin/autoreply/index'), // Parent router-view
        name: 'Autoreply',
        meta: { title: '自动回复管理' }
      },
      {
        path: 'autoreplyEdit',
        component: () => import('@/views/weixin/autoreply/autoreplyedit'), // Parent router-view
        name: 'AutoreplyEdit',
        meta: { title: '自动回复新增/编辑' },
        hidden: true
      },
      {
        path: 'config',
        name: 'Config',
        component: () => import('@/views/weixin/config/index'),
        meta: { title: '配置管理' }
      },
      {
        path: 'configEdit',
        component: () => import('@/views/weixin/config/configedit'), // Parent router-view
        name: 'ConfigEdit',
        meta: { title: '配置新增/编辑' },
        hidden: true
      },
      {
        path: 'menu',
        component: () => import('@/views/weixin/menu/index'), // Parent router-view
        name: 'Menu',
        meta: { title: '菜单配置' }
      },
      {
        path: 'source',
        name: 'Source',
        component: () => import('@/views/weixin/source/index'),
        meta: { title: '资源管理' }
      },
      {
        path: 'sourceEdit',
        component: () => import('@/views/weixin/source/sourceedit'), // Parent router-view
        name: 'SourceEdit',
        meta: { title: '资源新增/编辑' },
        hidden: true
      }
    ]
  },

  {
    path: '/material',
    component: Layout,
    redirect: '/material/imagematerial',
    name: 'Material',
    children: [
      {
        path: 'imagematerial',
        name: 'Imagematerial',
        component: () => import('@/views/material/imagematerial/index'),
        meta: { title: '素材管理', icon: 'link' }
      }
    ]
  },

  {
    path: '/card',
    component: Layout,
    redirect: '/card/cardmanage',
    name: 'Card',
    meta: {
      title: '卡券管理',
      icon: 'table'
    },
    children: [
      {
        path: 'cardmerchants',
        name: 'CardMerhants',
        component: () => import('@/views/card/cardmerchants/index'),
        meta: { title: '卡卷商户' }
      },
      {
        path: 'cardmanage',
        name: 'CardManage',
        component: () => import('@/views/card/cardoption/index'),
        meta: { title: '卡卷操作' }
      },
      {
        path: 'cardconsume',
        name: 'CardConsume',
        component: () => import('@/views/card/cardconsume/index'),
        meta: { title: '卡卷核销' }
      },
      {
        path: 'carddetail',
        name: 'CardDetail',
        component: () => import('@/views/card/cardoption/carddetail'),
        meta: { title: '卡卷详情' },
        hidden: true
      },
      {
        path: 'cardedit',
        name: 'CardEdit',
        component: () => import('@/views/card/cardoption/cardedit'),
        meta: { title: '卡卷新增/编辑' },
        hidden: true
      }
    ]
  },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
